﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CMP.ERP.Admin.ServiceReference1;

namespace CMP.ERP.Admin.Controllers
{
    public class calendarController : Controller
    {
        //
        // GET: /calendar/
        ServiceReference1.Service1Client client = new Service1Client();
        /// <summary>
        /// 显示仓库信息
        /// </summary>
        /// <returns></returns>
        public ActionResult calendar_Show()
        {
            ViewBag.CityID = new SelectList(client.ShowCity().ToList(), "CityID", "CityName");
            List<ServiceReference1.StorehouseInfo> list = new List<StorehouseInfo>();
            list = client.Storehouseshow().ToList();
            return View(list);
        }
        /// <summary>
        /// 添加仓库信息
        /// </summary>
        /// <param name="sth"></param>
        /// <returns></returns>
        public ActionResult calendar_Add(StorehouseInfo sth)
        {
            if (client.StorehouseAdd(sth) > 0)
            {
                return Content("<script>alert('添加成功');location.href='/calendar/calendar_Show'</script>");
            }
            else
            {
                return Content("<script>alert('添加失败');location.href='/calendar/calendar_Show'</script>");
            }
        }
        public ActionResult calendar_Delete(int id)
        {
            if (client.StorehouseDelete(id) > 0)
            {
                return Content("<script>alert('删除成功');location.href='/calendar/calendar_Show'</script>");
            }
            else
            {
                return Content("<script>alert('删除失败');location.href='/calendar/calendar_Show'</script>");
            }
        }
        public ActionResult calendar_Select(string SthName, string Sthcoding)
        {
            ViewBag.CityID = new SelectList(client.ShowCity().ToList(), "CityID", "CityName");
            List<ServiceReference1.StorehouseInfo> list = new List<StorehouseInfo>();
            list = client.StorehouseInfoSelect(SthName, Sthcoding).ToList();
            return View("calendar_Show",list);
        }
        public ActionResult calendar_Update(int id)
        {
            ViewBag.CityID = new SelectList(client.ShowCity().ToList(), "CityID", "CityName");
            return View(client.StorehouseGetID(id));
        }
        public ActionResult calendar_ShtUpdate(StorehouseInfo s)
        {
            if (client.StorehouseUpdate(s) > 0)
            {
                return Content("<script>alert('修改成功');location.href='/calendar/calendar_Show'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败');location.href='/calendar/calendar_Update'</script>");
            }
        }
    }
}
